<extend name="Public/base" />

<block name="body">
	<style type="text/css">
	.pic_ul li {float: left; width: 100px;}
	.pic_ul li img { vertical-align: middle;}
	.pic_ul li .title, .pic_ul li .action { text-align: center; width: 100px}
	</style>
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>版主管理【 {$circle.name} 】
		<button class="btn btn-default btn-return" onclick="javascript:history.back(-1);return false;"><i class="glyphicon glyphicon-share-alt"></i> 返 回</button></h2>
	</div>
	<div class="cf">
		<div class="fl">
			<a title="新增" class="btn btn-primary" data-toggle="modal" data-target="#addModal"><i class="glyphicon glyphicon-plus"></i></a>
           <!--  <button class="btn btn-default ajax-post" url="{:U('changeStatus',array('method'=>'resume'))}" target-form="ids"><i class="glyphicon glyphicon-ok-circle"></i> 启 用</button>
            <button class="btn btn-default ajax-post" url="{:U('changeStatus',array('method'=>'forbid'))}" target-form="ids"><i class="glyphicon glyphicon-ban-circle"></i> 禁 用</button> -->
            <!-- <button class="btn ajax-post confirm btn-danger" url="{:U('del')}" target-form="ids">删 除</button> -->
        </div>

        <!-- 高级搜索 -->
		<!-- <div class="search-form fr cf">
			<div class="sleft">
				<input type="text" name="name" class="search-input" value="{:I('name')}" placeholder="请输入游戏名">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
			</div>
		</div> -->
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="table table-bordered">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class=""></th>
		</tr>
    </thead>
    <tbody>
		 
	</tbody>
    </table>
    <ul class="pic_ul">
    	<volist name="_list" id="vo">
	 	<li>
	 		<label>
	 		<!-- <input class="ids" type="checkbox" name="uid[]" value="{$vo.uid}" /> -->
	 		<img alt="{$vo.user.nickname}" title="{$vo.user.nickname}" src="{:url_format($vo['user']['avatar'])}"  height="60" />
	 		</label>
	 		<div class="title">{$vo.user.nickname}</div>
	 		<div class="action"><a href="{:U('ajax_del?circle_id='.$circle['id'].'&uid='.$vo['uid'])}" class="confirm ajax-get btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a></div>
	 	</li>
	 	</volist>
	 </ul>
	</div>
    <div class="page">
        {$_page}
    </div>


    <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">X</span></button>
        <h4 class="modal-title" id="myModalLabel">添加管理员</h4>
      </div>
      <div class="modal-body">
      <div style="height: 80px;">
            <div class="row form-group form-group-sm">
                <label class="col-sm-3 control-label" for="addModalUid">填写前台用户UID</label>
            <div class="col-sm-9">
            <div class="input-group">
              <input class="form-control input-small" type="text" id="addModalUid" name="uid" >
              <!-- <div class="input-group-addon"><a href="{:U('frontUsers/index')}" target="_blank"><i class="glyphicon glyphicon-search"></i></a></div> -->
              </div>
            </div>
          </div>
          <div class="row form-group form-group-sm">
                <label class="col-sm-3 control-label" for="formGroupInputLarge">搜索昵称</label>
            <div class="col-sm-9">
            <div class="input-group">
              <input class="form-control input-small search-nickname-input" type="text" name="nickname" >
              <div class="input-group-addon"><a target="_blank"><i class="glyphicon glyphicon-search"></i></a></div>
              </div>
            </div>
          </div>
          <div class="form-group form-group-sm">
          <label class="col-sm-3 control-label" for="formGroupInputLarge"></label>
           <div class="col-sm-9">
          <div class="btn-group-vertical search-result-btn"></div>
          </div>
          </div>
      </div>    
      </div>
      <div class="modal-footer">
        <button type="button" onclick="add()" class="btn btn-primary">确定添加</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$('.search-nickname-input').keyup(function(){
  var nickname = $(this).val();
  var _field = $('.search-result-btn');
  _field.empty();
  $.get('{:U('UserDailyTop/search')}', {nickname: nickname}, function(res){
    $.each(res, function(k, item){
      var btn = '<button data-uid="'+item.id+'" type="button" class="btn btn-default search-uid-btn">'+item.nickname+'</button>';
      _field.append(btn);
    });
    $('.search-uid-btn').on('click', function(){
        var uid = $(this).data('uid');
        $('#addModalUid').val(uid);
    });
  });
});

</script>


</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    highlight_subnav('{:U('index')}');

    var circle_id = {$circle.id};

    function add() {
        var uid = $('input[name=uid]').val();
        $.post("{:U('add')}", {uid: uid, circle_id: circle_id}, function(data){
            if (data.status==1) {
                    if (data.url) {
                        updateAlert(data.info + ' 页面即将自动跳转~','alert-success');
                    }else{
                        updateAlert(data.info ,'alert-success');
                    }
                    location.reload();
                }else{
                    updateAlert(data.info);
                }
            
        });
    }

	</script>
</block>
